package com.coffee.service.impl;

import com.coffee.dao.ShoppingCartDAO;
import com.coffee.entity.ShoppingCart;
import com.coffee.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {

    @Autowired
    private ShoppingCartDAO shoppingCartDao;

    @Override
    public ShoppingCart getCoffeeById(String coffeeId, String userId) {
        return shoppingCartDao.selectCoffeeById(coffeeId,userId);
    }

    @Override
    public void updateById(ShoppingCart shoppingCart) {
        shoppingCartDao.updateById(shoppingCart);
    }

    @Override
    public void save(ShoppingCart shoppingCart) {
        shoppingCartDao.insert(shoppingCart);
    }

    @Override
    public List<ShoppingCart> list(String userId) {
        return shoppingCartDao.list(userId);
    }

    @Override
    public void remove(String userId) {
         shoppingCartDao.remove(userId);
    }

    @Override
    public void update(ShoppingCart shoppingCart) {
        shoppingCartDao.update(shoppingCart);
    }
}
